<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>北化论坛 - 发布帖子</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
    <h1>发布帖子</h1>
    <form id="postForm">
        <!-- 修改后的帖子内容输入框 -->
        <textarea placeholder="输入你的帖子内容..." required></textarea>
        <div class="file-input-container">
            <input type="file" accept="image/*">
        </div>
        <button type="submit">发布</button>
    </form>
</div>

<script>
    // 提交表单时执行的逻辑
    document.getElementById('postForm').addEventListener('submit', function(event) {
        event.preventDefault();  // 防止表单默认提交

        // 获取帖子内容和图片
        const content = event.target.querySelector('textarea').value;
        const file = event.target.querySelector('input[type="file"]').files[0];

        // 模拟后台数据提交和反馈
        if (content.trim()) {
            alert('帖子发布成功！');
            window.location.href = 'main.html?content=' + encodeURIComponent(content);  // 将帖子内容传递给main页面
        } else {
            alert('帖子内容不能为空');
        }
    });
</script>
</body>
</html>
